{% extends "customer/baseaccountpage.html" %}
{% load i18n %}
{% load currency_filters %}
{% load staticfiles %}

{% block breadcrumbs %}
    <ul class="breadcrumb">
        <li>
            <a href="{{ homepage_url }}">{% trans 'Home' %}</a>
        </li>
        <li>
            <a href="{% url 'customer:summary' %}">{% trans 'Account' %}</a>
        </li>
        <li class="active">{% trans 'Order history' %}</li>
    </ul>
{% endblock %}

{% block tabcontent %}

    {% if orders or form.is_bound %}
        <div class="well">
            <h2>{% trans "Filter" %}</h2>
            <form method="get" class="form-horizontal">
                {% include "partials/form_fields.html" with form=form style='horizontal' %}
                <div class="form-group">
                    <div class="col-sm-offset-4 col-sm-8">
                        <button type="submit" class="btn btn-primary" data-loading-text="{% trans 'Filtering...' %}">{% trans 'Filter results' %}</button>
                        <a href="{% url 'customer:order-list' %}" class="btn btn-default">{% trans 'Reset' %}</a>
                    </div>
                </div>
            </form>
        </div>
    {% endif %}

    {% if orders %}
        <h2>{{ form.description }}</h2>
        <table class="table table-striped table-bordered">
            <tr>
                <th>{% trans "Order number" %}</th>
                <th>{% trans "Num items" %}</th>
                <th>{% trans "Total inc tax" %}</th>
                <th>{% trans "Date submitted" %}</th>
            </tr>
            {% for order in orders %}
                <tr>
                    <td><a href="{% url 'customer:order' order_number=order.number %}">{{ order.number }}</a></td>
                    <td>{{ order.num_items }}</td>
                    <td>{{ order.total_incl_tax|currency:order.currency }}</td>
                    <td>{{ order.date_placed }}</td>
                </tr>
            {% endfor %}
        </table>
        {% include "partials/pagination.html" %}
    {% else %}
        {% if form.is_bound %}
            <p>{% trans "No orders match your search." %}</p>
        {% else %}
            <p>{% trans "You haven't placed any orders." %}</p>
        {% endif %}
    {% endif %}

{% endblock tabcontent %}
